def print_file_info(file_name):
    """
    print file info
    :param file_name: file name
    :return: None
    """
    f = None
    try:
        f = open(file_name, "r", encoding="UTF-8")
        print(f.read())
    except Exception as error:
        print(error)
    finally:
        if f:
            f.close()

def append_to_file(file_name, data):
    """
    向 file_name 中追加 data
    :param file_name: 文件名
    :param data: 追加数据
    :return: None
    """
    f = None
    try:
        f = open(file_name, "a", encoding="UTF-8")
        f.write(data)
    except Exception as error:
        print(error)
    finally:
        if f:
            f.close()

if __name__ == '__main__':
    print_file_info("test.txt")
    append_to_file("test.txt", "111")